package Leetcode;

import java.util.Stack;

public class problem_232 {
    Stack<Integer> Lstack;
    Stack<Integer> Rstack;

    /** Initialize your data structure here. */
    public problem_232() {
        Lstack = new Stack<>();
        Rstack = new Stack<>();
    }

    /** Push element x to the back of queue. */
    public void push(int x) {
        Lstack.push(x);
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        if(Rstack.isEmpty()){
            while(!Lstack.isEmpty()){
                Rstack.push(Lstack.pop());
            }
        }
        return Rstack.pop();
    }

    /** Get the front element. */
    public int peek() {
        if(Rstack.isEmpty()){
            while(!Lstack.isEmpty()){
                Rstack.push(Lstack.pop());
            }
        }
        return Rstack.peek();
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return Lstack.isEmpty() && Rstack.isEmpty();
    }

}
